import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/index'
  },

  {
    path: '/login',
    name: 'logins',
    component: () => import(/* webpackChunkName: "gds" */ '@/views/login/index.vue')
  },
  {
    path: '/index',
    name: 'Index',
    component: () => import(/* webpackChunkName: "gds" */ '@/views/index/index.vue')
  },
  {
    path: '/redian',
    name: 'Redian',
    component: () => import(/* webpackChunkName: "gds" */ '@/views/redian/index.vue')
  },
  {
    path: '/game',
    name: 'Game',
    component: () => import(/* webpackChunkName: "gds" */ '@/views/game/index.vue')
  },
  {
    path: '/wode',
    name: 'Wode',
    component: () => import(/* webpackChunkName: "gds" */ '@/views/wode/index.vue')
  },
  {
    path: '/main',
    name: 'main',
    component: () => import(/* webpackChunkName: "gds" */ '@/views/main.vue'),
    children: [
      {
        path: '/article',
        name: 'article',
        meta: { title: '解密时刻' },
        component: () => import(/* webpackChunkName: "gds" */ '@/views/redian/article.vue')
      },
      {
        path: '/person',
        name: 'person',
        meta: { title: '个人信息' },
        component: () => import(/* webpackChunkName: "gds" */ '@/views/wode/person.vue')
      },
      {
        path: '/update',
        name: 'update',
        meta: { title: '' },
        component: () => import(/* webpackChunkName: "gds" */ '@/views/wode/input.vue'),
        beforeEnter: (to, form, next) => {
          if (to.name === 'update') {
            to.meta.title = to.params.title
            next()
          }
        }
      },
      {
        path: '/diy',
        name: 'diy',
        meta: { title: '拖拽组件' },
        component: () => import(/* webpackChunkName: "gds" */ '@/views/diy/index.vue')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
